<?php

/**
 * This is the model class for table "adjustment".
 *
 * The followings are the available columns in table 'adjustment':
 * @property string $id
 * @property string $adjustment_number
 * @property string $adjustment_number_seq
 * @property string $adjustment_date
 * @property string $part_code
 * @property string $current_stock
 * @property string $stock_status
 * @property string $adjustment_qty
 * @property double $last_unit_price
 * @property string $last_stock
 * @property double $unit_price
 * @property double $current_unit_price
 */
class Adjustment extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Adjustment the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'adjustment';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('last_unit_price, unit_price, current_unit_price', 'numerical'),
			array('adjustment_number, part_code', 'length', 'max'=>50),
			array('adjustment_number_seq, current_stock, adjustment_qty, last_stock', 'length', 'max'=>19),
			array('stock_status', 'length', 'max'=>3),
			array('adjustment_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, adjustment_number, adjustment_number_seq, adjustment_date, part_code, current_stock, stock_status, adjustment_qty, last_unit_price, last_stock, unit_price, current_unit_price', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'adjustment_number' => 'Adjustment Number',
			'adjustment_number_seq' => 'Adjustment Number Seq',
			'adjustment_date' => 'Adjustment Date',
			'part_code' => 'Part Code',
			'current_stock' => 'Current Stock',
			'stock_status' => 'Stock Status',
			'adjustment_qty' => 'Adjustment Qty',
			'last_unit_price' => 'Last Unit Price',
			'last_stock' => 'Last Stock',
			'unit_price' => 'Unit Price',
			'current_unit_price' => 'Current Unit Price',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('adjustment_number',$this->adjustment_number,true);
		$criteria->compare('adjustment_number_seq',$this->adjustment_number_seq,true);
		$criteria->compare('adjustment_date',$this->adjustment_date,true);
		$criteria->compare('part_code',$this->part_code,true);
		$criteria->compare('current_stock',$this->current_stock,true);
		$criteria->compare('stock_status',$this->stock_status,true);
		$criteria->compare('adjustment_qty',$this->adjustment_qty,true);
		$criteria->compare('last_unit_price',$this->last_unit_price);
		$criteria->compare('last_stock',$this->last_stock,true);
		$criteria->compare('unit_price',$this->unit_price);
		$criteria->compare('current_unit_price',$this->current_unit_price);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}